import { useEffect, useRef } from 'react'

function useCustomEffect(effect: () => void | (() => void), dependencies?: React.DependencyList) {
  const isInitialMount = useRef(true);

  useEffect(() => {
    if (isInitialMount.current) {
      effect()
      isInitialMount.current = false;
    } else {

    }
    return () => {
      const cleanup = effect();
      if (cleanup && typeof cleanup === 'function') {
        cleanup();
      }
    };
  }, dependencies);
}

export { useCustomEffect }